import hashlib

m = hashlib.md5()
m.update(b'hello')
print(m.hexdigest())

import base64
# base64编码
m = base64.b64encode(b'my name is huhx.')
print(m) # ZGF0YSB0byBiZSBlbmNvZGVk

# # base64解码
bytes = base64.b64decode(m)
print(bytes)

print('中国'.encode('utf-8')) # b'\xe4\xb8\xad\xe5\x9b\xbd'
print('中国'.encode('gbk')) # b'\xd6\xd0\xb9\xfa'

import codecs
print(codecs.encode('中国', 'utf-8')) # b'\xe4\xb8\xad\xe5\x9b\xbd'
print(codecs.encode('中国', 'gbk')) # b'\xd6\xd0\xb9\xfa'